package com.tn.openrpc.jms.acceptance.performance;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * The server side of the performance acceptance test, which runs the Active MQ broker, Echo service and listens for RPC
 * requests.
 */
public class Server
{
  private static final String APPLICATION_CONTEXT_FILE = "performance/server.xml";

  public static boolean running = true;

  /**
   * Program entry point.
   */
  public static void main(String[] args)
  {
    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
      APPLICATION_CONTEXT_FILE
    );
    applicationContext.start();

    while (running)
    {
      sleep(1000);
    }
  }

  /**
   * Sleeps the calling thread for the specified number of <code>millis</code>.
   */
  private static void sleep(long millis)
  {
    try
    {
      Thread.sleep(millis);
    }
    catch (InterruptedException e)
    {
      //ignore.
    }
  }
}
